import { Routes, Route, Navigate } from "react-router";
import NotFountPage from "@/page/404";
import Layout from "@/layout";
import LoginPage from "@/page/login";
import HomePage from "@/page/home";
import PrivateRoute from "./PrivateRoute";

const RoutesElement = () => {
  return (
    <Routes>
      {/* 默认路由-重定向 */}
      <Route path="/" element={<Navigate to="/dashboard" replace />} />

      {/* 登录 */}
      <Route path="login" element={<LoginPage />} />

      {/* 受保护的路由 */}
      <Route
        path="dashboard"
        element={
          <PrivateRoute>
            <Layout />
          </PrivateRoute>
        }
      >
        <Route index element={<HomePage />} />
      </Route>

      {/* 404页面 */}
      <Route path="*" element={<NotFountPage />} />
    </Routes>
  );
};

export default RoutesElement;
